package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @Description 租赁空间-出租状态枚举
 * @Param
 * @Return
 * @Date 2023/5/15 15:50
 * @Author Link
 **/
@Getter
@AllArgsConstructor
public enum RentSpaceRentStatusEnum {
    EMPTY("1","空房"),
    SCHEDULED("2","已出租"),
    ;

    private String value;
    private String name;

    public static String getValueByName(String name) {
        RentSpaceRentStatusEnum rentStatusEnum = Arrays.stream(RentSpaceRentStatusEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(rentStatusEnum != null,"RentStatusEnum类型:{}不存在",name);
        return rentStatusEnum.getValue();
    }

    public static String getName(String value) {
        RentSpaceRentStatusEnum first = Arrays.stream(RentSpaceRentStatusEnum.values()).filter(s -> value.equals(s.getValue())).findFirst().orElse(null);
        if (first == null) {
            return "";
        }
        return first.getName();
    }
}
